﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Examenes.aspx.cs" Inherits="Ent.Inscripcion.Presentacion.Administracion.Examenes" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Administrar Horario de Exámenes</title>
    <ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="Script" />
    <script type="text/javascript" src="../Resources/Js/EntInscripcion.js"></script>
</head>
<body>
    <ext:ResourceManager ID="ResourceManager1" runat="server" />
    <ext:Hidden ID="hidIdExamen" runat="server">
    </ext:Hidden>
    <ext:Hidden ID="hidAccionExamen" runat="server">
    </ext:Hidden>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="Fit">
        <LayoutConfig>
            <ext:VBoxLayoutConfig Align="Stretch" />
        </LayoutConfig>
        <Items>
            <ext:Panel ID="Panel2" BodyStyle="background-color:transparent;" Padding="10" Border="false"
                runat="server" ButtonAlign="Center">
                <Items>
                    <ext:FormPanel ID="frpDatosBusqueda" BodyStyle="background-color:transparent;" runat="server"
                        Border="false" Layout="Column" LabelWidth="70" ButtonAlign="Center">
                        <Items>
                            <ext:Panel ID="Panel3" runat="server" ColumnWidth="0.5" Height="25" Border="false"
                                Layout="Form">
                                <Items>
                                    <ext:ComboBox ID="cbxNivelB" runat="server" Editable="false" DisplayField="Nombre"
                                        ValueField="Id" FieldLabel="Nivel" Mode="Local" AnchorHorizontal="95%" EmptyText="Seleccione..">
                                        <Store>
                                            <ext:Store runat="server" ID="stoNiveles">
                                                <Reader>
                                                    <ext:JsonReader IDProperty="Id">
                                                        <Fields>
                                                            <ext:RecordField Name="Id" />
                                                            <ext:RecordField Name="Codigo" />
                                                            <ext:RecordField Name="Nombre" />
                                                            <ext:RecordField Name="Descripcion" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                            </ext:Store>
                                        </Store>
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip1" runat="server" Title="Nivel de inglés">
                                            </ext:ToolTip>
                                        </ToolTips>
                                        <Triggers>
                                            <ext:FieldTrigger Icon="Clear" Qtip="Limpiar" />
                                        </Triggers>
                                        <Listeners>
                                            <TriggerClick Handler="this.clearValue();" />
                                        </Listeners>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Panel>
                            <ext:Panel ID="Panel6" runat="server" ColumnWidth="0.5" Border="false" Layout="Form">
                                <Items>
                                    <ext:ComboBox ID="cbxDiaB" runat="server" AnchorHorizontal="95%" Editable="false"
                                        DisplayField="Nombre" ValueField="Id" FieldLabel="Día" Mode="Local" EmptyText="Seleccione..">
                                        <Store>
                                            <ext:Store runat="server" ID="stoDias">
                                                <Reader>
                                                    <ext:JsonReader IDProperty="Id">
                                                        <Fields>
                                                            <ext:RecordField Name="Id" />
                                                            <ext:RecordField Name="Codigo" />
                                                            <ext:RecordField Name="Nombre" />
                                                            <ext:RecordField Name="Descripcion" />
                                                        </Fields>
                                                    </ext:JsonReader>
                                                </Reader>
                                            </ext:Store>
                                        </Store>
                                        <ToolTips>
                                            <ext:ToolTip ID="ToolTip3" runat="server" Title="Día del exámen">
                                            </ext:ToolTip>
                                        </ToolTips>
                                        <Triggers>
                                            <ext:FieldTrigger Icon="Clear" Qtip="Limpiar" />
                                        </Triggers>
                                        <Listeners>
                                            <TriggerClick Handler="this.clearValue();" />
                                        </Listeners>
                                    </ext:ComboBox>
                                </Items>
                            </ext:Panel>
                        </Items>
                        <Buttons>
                            <ext:Button ID="btnBuscar" runat="server" Text="Buscar">
                                <DirectEvents>
                                    <Click Before="#{stoExamenes}.removeAll();" OnEvent="btnBuscar_Click">
                                        <ExtraParams>
                                            <ext:Parameter Name="Nivel" Value="#{cbxNivelB}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                            <ext:Parameter Name="Dia" Value="#{cbxDiaB}.getValue()" Mode="Raw">
                                            </ext:Parameter>
                                        </ExtraParams>
                                        <EventMask Msg="Buscando Examenes" ShowMask="true" />
                                    </Click>
                                </DirectEvents>
                            </ext:Button>
                        </Buttons>
                    </ext:FormPanel>
                </Items>
            </ext:Panel>
            <ext:GridPanel ID="gdpExamenes" runat="server" StripeRows="true" AutoWidth="true"
                Height="600">
                <Store>
                    <ext:Store runat="server" ID="stoExamenes" GroupField="Niveles">
                        <Reader>
                            <ext:JsonReader IDProperty="BaseId">
                                <Fields>
                                    <ext:RecordField Name="BaseId" />
                                    <ext:RecordField Name="Id" />
                                    <ext:RecordField Name="Nivel" />
                                    <ext:RecordField Name="Niveles" />
                                    <ext:RecordField Name="Dia" />
                                    <ext:RecordField Name="HoraInicio" Type="Date" />
                                    <ext:RecordField Name="HoraFin" Type="Date" />
                                    <ext:RecordField Name="Estado" />
                                    <ext:RecordField Name="Cupo" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <TopBar>
                    <ext:Toolbar ID="Toolbar3" runat="server">
                        <Items>
                            <ext:Button ID="btnCrearExamen" runat="server" Text="Crear Examen" Icon="PageAdd">
                                <Listeners>
                                    <Click Handler="LimpiarForm();#{winExamenes}.show();#{hidAccionExamen}.setValue('Nuevo');" />
                                </Listeners>
                            </ext:Button>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel3" runat="server">
                    <Columns>
                        <ext:CommandColumn Width="120" Header="Acciones">
                            <Commands>
                                <ext:GridCommand CommandName="Editar" Text="Editar" Icon="PageEdit" ToolTip-Text="Editar Examen">
                                </ext:GridCommand>
                                <ext:GridCommand CommandName="Eliminar" Text="Eliminar" Icon="PageDelete" ToolTip-Text="Eliminar Examen">
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>                        
                        <ext:Column Header="Nivel" Width="150" Sortable="true" DataIndex="Nivel"/>
                        <ext:Column Header="Dia" Width="150" Sortable="true" DataIndex="Dia" />
                        <ext:Column Header="Niveles" Width="100" Sortable="true" DataIndex="Niveles"/>
                        <ext:DateColumn Header="Hora Inicio" Width="100" Sortable="true" DataIndex="HoraInicio"
                            Format="H:mm">
                        </ext:DateColumn>
                        <ext:DateColumn Header="Hora Fin" Width="100" Sortable="true" DataIndex="HoraFin"
                            Format="H:mm">
                        </ext:DateColumn>
                        <ext:Column Header="Cupo" Width="100" Sortable="true" DataIndex="Cupo"/>
                        <ext:CheckColumn Header="Activo" Width="100" Sortable="true" DataIndex="Estado"/>
                    </Columns>
                </ColumnModel>
                <View>
                <ext:GroupingView ID="GroupingView1"
                    runat="server"
                    ForceFit="true"
                    MarkDirty="false"
                    ShowGroupName="false"
                    EnableNoGroups="true"
                    HideGroupedColumn="true"
                    
                    />
            </View>
                <DirectEvents>
                    <Command OnEvent="ManejarAccion">
                        <ExtraParams>
                            <ext:Parameter Name="Comando" Value="command" Mode="Raw" Encode="false" />
                            <ext:Parameter Name="Id" Value="record.data.Id" Mode="Raw" />
                        </ExtraParams>
                    </Command>
                </DirectEvents>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel3" runat="server" SingleSelect="true">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <LoadMask Msg="Cargando Datos" ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <ext:Window ID="winExamenes" runat="server" Icon="Application" Title="Administrar Exámenes"
        Modal="True" AutoHeight="true" Width="400px" Y="5" CenterOnLoad="true" Hidden="true"
        ButtonAlign="Center" Resizable="false">
        <Items>
            <ext:FormPanel ID="frpDatosExamen" runat="server" BodyStyle="padding:10px;" ButtonAlign="Center"
                Layout="Form" Hidden="false" AnimCollapse="true" LabelWidth="80">
                <Items>
                    <ext:MultiCombo ID="cbNivel" runat="server" Editable="false" DisplayField="Nombre"
                        AllowBlank="false" ValueField="Id" FieldLabel="Nivel" Mode="Local" AnchorHorizontal="95%"
                        EmptyText="Seleccione.." StoreID="stoNiveles">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip2" runat="server" Title="Nivel de inglés">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:MultiCombo>
                    <ext:ComboBox ID="cbDia" runat="server" AnchorHorizontal="95%" Editable="false" DisplayField="Nombre"
                        AllowBlank="false" ValueField="Id" FieldLabel="Día" Mode="Local" EmptyText="Seleccione.."
                        StoreID="stoDias">
                        <ToolTips>
                            <ext:ToolTip runat="server" Title="Día del exámen">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:ComboBox>
                    <ext:TimeField ID="tfHoraInicio" AllowBlank="false" FieldLabel="Hora Inicio" runat="server"
                        MinTime="7:00" MaxTime="21:00" Increment="15" Format="H:mm">
                        <ToolTips>
                            <ext:ToolTip runat="server" Title="Hora de inicio del exámen">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:TimeField>
                    <ext:TimeField ID="tfHoraFin" AllowBlank="false" FieldLabel="Hora Fin" runat="server"
                        MinTime="7:00" MaxTime="21:00" Increment="15" Format="H:mm">
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip6" runat="server" Title="Hora de finalización del exámen">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:TimeField>
                    <ext:ComboBox ID="cbxAula" runat="server" AnchorHorizontal="95%" Editable="false"
                        DisplayField="Nombre" AllowBlank="false" ValueField="Id" FieldLabel="Aula" Mode="Local"
                        EmptyText="Seleccione..">
                        <Store>
                            <ext:Store runat="server" ID="stoAulas">
                                <Reader>
                                    <ext:JsonReader IDProperty="Id">
                                        <Fields>
                                            <ext:RecordField Name="Id" />
                                            <ext:RecordField Name="Codigo" />
                                            <ext:RecordField Name="Nombre" />
                                            <ext:RecordField Name="Descripcion" />
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                        </Store>
                    </ext:ComboBox>
                    <ext:NumberField runat="server" ID="nbfCupo" MinValue="1" FieldLabel="Cupos" AllowBlank="false" AnchorHorizontal="95%"></ext:NumberField>
                    <ext:ComboBox ID="cbxEstado" runat="server" AnchorHorizontal="95%" Editable="false"
                        DisplayField="text" AllowBlank="false" SelectedIndex="0" ValueField="value" FieldLabel="Estado"
                        Mode="Local">
                        <Items>
                            <ext:ListItem Text="Activo" Value="1" />
                            <ext:ListItem Text="Inactivo" Value="0" />
                        </Items>
                        <ToolTips>
                            <ext:ToolTip ID="ToolTip4" runat="server" Title="Estado del exámen">
                            </ext:ToolTip>
                        </ToolTips>
                    </ext:ComboBox>
                </Items>
            </ext:FormPanel>
        </Items>
        <Buttons>
            <ext:Button runat="server" ID="btnEliminar" Text="Eliminar" Hidden="true" Icon="Delete">
                <DirectEvents>
                    <Click OnEvent="btnEliminar_Click" Failure="ManejarError();" Success="LimpiarForm();#{winExamenes}.hide();MostrarMensaje(3,'El Examen se elimino correctamente');">
                        <EventMask ShowMask="true" Msg="Eliminando Examen" />
                        <ExtraParams>
                            <ext:Parameter Name="Id" Value="#{hidIdExamen}.getValue()" Mode="Raw" />
                        </ExtraParams>
                        <Confirmation Message="Esta seguro de eliminar el Examen?" ConfirmRequest="true" />
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="btnGuardar" Text="Guardar" Icon="Add">
                <DirectEvents>
                    <Click Before="return ValidarFormulario(#{frpDatosExamen});" OnEvent="btnGuardar_Click"
                        Failure="ManejarError();" Success="LimpiarForm();#{winExamenes}.hide();MostrarMensaje(3,'El Examen se guardo correctamente');">
                        <EventMask ShowMask="true" Msg="Guardando datos" />
                        <ExtraParams>
                            <ext:Parameter Name="Accion" Value="#{hidAccionExamen}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Id" Value="#{hidIdExamen}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Nivel" Value="#{cbNivel}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Dia" Value="#{cbDia}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="HoraInicio" Value="#{tfHoraInicio}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="HoraFin" Value="#{tfHoraFin}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Estado" Value="#{cbxEstado}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Aula" Value="#{cbxAula}.getValue()" Mode="Raw" />
                            <ext:Parameter Name="Cupo" Value="#{nbfCupo}.getValue()" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" ID="btnCancelar" Text="Cancelar" Icon="Stop">
                <Listeners>
                    <Click Handler="LimpiarForm();#{winExamenes}.hide();" />
                </Listeners>
            </ext:Button>
        </Buttons>
    </ext:Window>
    <ext:XScript ID="XScript1" runat="server">

    <script type="text/javascript">
        var LimpiarForm = function () { 
            #{frpDatosExamen}.getForm().reset();
        };
    </script>
    </ext:XScript>
</body>
</html>
